package com.pengshun.modules.api.mapper;

import com.pengshun.modules.api.order.service.dto.MerchantOrderDto;
import com.pengshun.modules.api.pay.service.dto.WchatPayResult;
import com.pengshun.modules.api.system.domain.Province;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

public interface OrderMapper {

    /**
     * 操作表添加记录
     */

    @Insert("INSERT INTO `ps_merchant_order_record` (  `order_id`,  `user_id`,  `order_status`,`remark`,`username` " +
            ") VALUES(#{orderId},#{userId},#{orderStatus},#{remark},#{name})")
    int saveOrderRecord(@Param("orderId") Long orderId,@Param("userId") Long userId,@Param("orderStatus") Integer orderStatus,@Param("remark") String remark,@Param("name") String name);

    /**
     * 煤炭数量更新
     * @param nowCoalNumber
     * @param oldCoalNumber
     * @param id
     */
    @Update("update ps_merchant_coal set coal_number=#{nowCoalNumber} where merchant_coal_id=#{id} and coal_number=#{oldCoalNumber} ")
    int updateMerchantCoalNumber(@Param("nowCoalNumber")BigDecimal nowCoalNumber,@Param("oldCoalNumber") BigDecimal oldCoalNumber,@Param("id") Long id);

    /**
     * 查询用户不同状态订单列表
     * @param userId
     * @param type
     * @param page
     * @param size
     * @return
     */
    List<MerchantOrderDto> selectUserOrderList(@Param("userId")Long userId, @Param("type")Integer type,@Param("page") int page,@Param("size") Integer size);

    /**
     * 查询商户不同状态订单列表
     * @param userId
     * @param type
     * @param page
     * @param size
     * @return
     */
    List<MerchantOrderDto> selectMerchantOrderList(@Param("userId")Long userId, @Param("type")Integer type,@Param("page") int page,@Param("size") Integer size);

    /**
     * 订单详情
     * @param orderId
     * @return
     */
    MerchantOrderDto orderDetil(@Param("orderId")Long orderId);

    List<Province> selectAllProvice();

    int insertPayWchatResult(WchatPayResult result);

    /**
     * 查询支付
     * @param outTradeNo
     * @return
     */
    @Select("select total_fee   from  `ps_bill_pay` where out_trade_no=#{outTradeNo}")
    WchatPayResult selectpayMoney(@Param("outTradeNo") String outTradeNo);
}
